
@echo off
setlocal enabledelayedexpansion

:: Vulkan SDK glslc路径，根据你的系统和版本修改
set GLSLC_PATH=C:\VulkanSDK\1.3.296.0\Bin\glslc.exe

:: 检查glslc是否存在
if not exist "%GLSLC_PATH%" (
    echo Error: glslc.exe not found at "%GLSLC_PATH%".
    echo Please check your Vulkan SDK installation and update the path.
    pause
    exit /b
)

:: 创建子目录 src_spirv（如果不存在）
if not exist "src_spirv" (
    mkdir src_spirv
)

:: 遍历当前目录的所有 .vert 和 .frag 文件
for %%F in (*.vert *.frag) do (
    echo Compiling %%F ...
    "%GLSLC_PATH%" %%F -o src_spirv\%%F.spv
    if %errorlevel% equ 0 (
        echo Successfully compiled: %%F to src_spirv\%%F.spv
    ) else (
        echo Failed to compile: %%F
    )
)

:: 完成后暂停以查看输出
echo Compilation complete. All SPIR-V files saved in the src_spirv directory.
pause

